
using SharpWind.Gui;
using SharpWind.Scene.Cameras;
using System.Collections.Generic;

using Microsoft.DirectX.Direct3D;
using Microsoft.DirectX;

namespace SharpWind.Scene
{
	public sealed class SceneManager
	{
		private SceneNode root = new SceneNode();

		private GuiManager guiManager = new GuiManager();

		private Dictionary<string, Camera> cameras = new Dictionary<string,Camera>();

		private Camera activeCamera = null;

		internal SceneManager()
		{
			
		}

		internal void Render()
		{
			if( this.activeCamera != null )
			{
				Engine.Instance.Renderer.Device.Transform.View =
					Matrix.LookAtLH( new Vector3( 0, 5, -25 ), new Vector3( 0, 5, 0 ), new Vector3( 0, 1, 0 ) );
				Engine.Instance.Renderer.Device.Transform.Projection =
					Matrix.PerspectiveFovLH( Geometry.DegreeToRadian( 45f ), 1f, 1f, 1000f );

				//Engine.Instance.Renderer.Device.Transform.View = this.activeCamera.ViewMatrix;
				//Engine.Instance.Renderer.Device.Transform.Projection = this.activeCamera.ProjectionMatrix;
			}
		
			Root.Process();
			Controls.Render();
		}

		public SceneNode Root
		{
			get
			{
				return this.root;
			}
		}

		public GuiManager Controls
		{
			get
			{
				return this.guiManager;
			}
		}
		
		public Dictionary<string, Camera> Cameras
		{
			get
			{
				return this.cameras;
			}
		}
		
		public Camera ActiveCamera
		{
			get
			{
				return this.activeCamera;
			}
			set
			{
				this.activeCamera = value;
			}
		}
	}
}
